﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Threading;

namespace ObjectSync
{
    class ImmediateInvoke : ISynchronizeInvoke
    {

        // The thread for processing delegates.
        private Thread delegateThread;

        #region ISynchronizeInvoke Members

        public IAsyncResult BeginInvoke(Delegate method, object[] args)
        {
            throw new NotImplementedException();
        }

        public object EndInvoke(IAsyncResult result)
        {
            throw new NotImplementedException();
        }

        public object Invoke(Delegate method, object[] args)
        {
            return method.DynamicInvoke(args);
        }

        public bool InvokeRequired
        {
            get
            {
                return Thread.CurrentThread.ManagedThreadId !=
                                                delegateThread.ManagedThreadId;
            }
        }

        #endregion
    }
}
